package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/1/18 11:02
 * @description
 */
public class Code671 {
    private List<Integer> list = new ArrayList<>();

    public int findSecondMinimumValue(TreeNode root) {
        setList(root);
        Collections.sort(list);
        int min = list.get(0);
        for (Integer i : list) {
            if (i > min) {
                return i;
            }
        }
        return -1;
    }

    private void setList(TreeNode node) {
        if (node != null) {
            list.add(node.val);
            setList(node.left);
            setList(node.right);
        }
    }
}
